package com.konglz.consumer.listener;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Description
 * @Author konglz
 * @Data 2023/5/13 12:38
 */
@Component
public class DirectMessageListener {

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "directQueue1"),
            exchange = @Exchange(name = "konglz.direct",type = ExchangeTypes.DIRECT),
            key = {"user","role"}
    ))
    public void listenDirectQueue1(String message){
        System.out.println("directQueue1消费者接收到的消息：" + message);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "directQueue2"),
            exchange = @Exchange(name = "konglz.direct",type = ExchangeTypes.DIRECT),
            key = {"user","menu"}
    ))
    public void listenDirectQueue2(String message){
        System.out.println("directQueue2消费者接收到的消息：" + message);
    }
}
